<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="业务单结清" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doShow(id){
		var url="/business/BusinessBillInfoForClose.ihtm?id="+id;
		ShowIframe("业务单结清",url,900,500,"refreshWin()",1024,600);
	}
	function refreshWin(){
		if(popRetVal!=null){
			window.location.reload(true);
		}
	}
	function doClose(id){
		ShowConfirm('确认框','确定结清吗？',340,80,"doCloseCallBack('"+id+"')");
	}
	function doCloseCallBack(id){
		if(popRetVal!=null){
			var url="/business/BusinessBillClose.ihtm?id_str="+id;
			ShowIframe("业务单结清",url,200,200,"refreshWin()");
		}
	}
	function doMutiClose(){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		for (i=0;i<ob_arr.length;i++){
			if ((ob_arr[i].checked == true)){
				if(str!=""){
					str=str+";";
				}
				str = str+ob_arr[i].value;
			}
		}
		
		if(str!=""){
			doClose(str);
		}else{
			ShowAlert('提示框','请选择要结清的业务单',200,100);
		}
	}
	function doSearch(){
		var cost=document.getElementById("cost").value;
		var status=document.getElementById("status").value;
		var tsId=document.getElementById("ts_id").value;
		var searchKey=encodeURIComponent(document.getElementById("search_key").value.trim());
		var orderBy=document.getElementById("order_by").value;
		window.location="/business/BusinessBillListForClose.ihtm?cost="+cost+"&search_key="+searchKey+"&ts_id="+tsId+"&status="+status+"&order_by="+orderBy;
	}
	function doGo(pageIndex){
		var searchKey=encodeURIComponent("${searchKey}");
		window.location="/business/BusinessBillListForClose.ihtm?cost=${cost}&ts_id=${tsId}&status=${status}&order_by=${orderBy}&search_key="+searchKey+"&current_page="+pageIndex;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function doDownload(){
		var searchKey=encodeURIComponent("${searchKey}");
		window.location="/business/BusinessBillListForClose.ihtm?cost=${cost}&ts_id=${tsId}&status=${status}&order_by=${orderBy}&search_key="+searchKey+"&content_type=EXCEL";
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		if(ob_arr.length>=it.getAttribute("index")){
			str=ob_arr[it.getAttribute("index")-1].value;
		}
		if(str==""){
			return;
		}
		doShow(str);
	}
	function doCancel(){
		window.close();
	}
	function doInit(){
		//Window_Onload();
		document.getElementById("search_key").focus();
	}
	function checkSearchKey(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function showRelBill(code){
		showWin(1024,600,"/business/BusinessRelBillList.ihtm?code="+encodeURIComponent(code));
	}
	function doPrint(id){
		showWin(900,600,"/business/BusinessBillPrint.ihtm?id="+id+"&type=LITTLE");
	}
</script>
</head>
<body oncontextmenu="return false" onLoad="doInit();" class="sheet" style="text-align:center;">
<div class="sheet-main" style="width:980px;text-align:left;margin:auto;">
  <div class="sheet-top">
    <div class="content">
      <h2>业务单结清</h2>
      <p>已收完款的业务单才会出现在这里，结清后的业务单不再参与相关业务选择，也不可以做任何修改</p>
    </div>
  </div>
  <div class="sheet-list">
    <div class="search-business">
      <div class="content">
        <table width="868">
          <tbody>
            <tr>
              <td  align="right">
              	<select name='ts_id' id="ts_id">
					<option value="0">==请选择账套==</option>
					<c:forEach var="item" items="${tsList}">
					<option value="${item.id}" <c:if test="${tsId==item.id}">selected</c:if>>${item.title}</option>
					</c:forEach>
	  		  	</select>
              	<select id="cost" name="cost">
              		<option value="ALL">==金额==</option>
              		<option value="ZERO" <c:if test="${cost=='ZERO'}">selected</c:if>>金额为0</option>
              		<option value="NOT_ZERO" <c:if test="${cost=='NOT_ZERO'}">selected</c:if>>金额不为0</option>
              	</select>
              	<select id="status" name="status">
              		<option value="ALL">==完工送货状态==</option>
              		<option value="COMP_DELI" <c:if test="${status=='COMP_DELI'}">selected</c:if>>已完工已送完</option>
              	</select>
	            <input type="text" class="TextBox" id="search_key" name="search_key" onKeyUp="checkSearchKey();" style="width:100px" value="${searchKey}" title="以客户名称、客户拼音字头、摘要、业务单号进行模糊查询">
	            <select id="order_by" name="order_by">
              		<option value="">==排序==</option>
              		<option value="RECE_DATE" <c:if test="${orderBy=='RECE_DATE'}">selected</c:if>>最近回款日期</option>
              		<option value="ORDER_DATE" <c:if test="${orderBy=='ORDER_DATE'}">selected</c:if>>订货日期</option>
              	</select>
	            <input type="button" class="buttom search-but" value=" 查 询" onClick="doSearch();">
	            <input type="button" class="buttom search-out" value=" 导 出" onClick="doDownload();" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>
				<input type="button" class="buttom search-close" value=" 结 清" onClick="doMutiClose();" title="以客户名称、客户拼音字头、摘要、业务单号进行模糊查询">	              
			  </td>
            </tr>    
           </tbody>      
        </table>
      </div>
	  <%@include file="../inc/AlertMsg.jsp"%>
	  
	  <c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_TOTA;')==-1}">
	  <div class="cue-info">
      	<span>金额合计：${costTotal}元</span>
	  </div>
	  </c:if>
	  
	  <div class="table-list">
        <table width="100%">      
				<tr >
					<th width="14"><input type="checkbox" onClick="javascript:checkall(this);"></th>
					<th  width="12%">单号</th>
					<th  width="8%">订货日期</th>
					<th  width="12%">订货单位</th>
					<th  width="12%">摘要</th>
					<th  width="8%">金额</th>
					<th  width="8%">调账</th>
					<th  width="8%">交货日期</th>
					<th  width="9%">最近回款日期</th>
					<th  width="10%">跟单员</th>
					<th  width="6%">状态</th>
					<th  width="9%">操作</th>
				</tr>
				<c:forEach var="item" items="${qr.list}" varStatus="i">
					<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
					<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
					<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this,true)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
						<td><input type="checkbox" onClick="javascript:ClickCheck(this,true);" name='query_checkbox' value="${item[0].id}"></td>
						<td>${item[0].billCode}</td>
						<td><fmt:formatDate value="${item[0].orderDate}" pattern="yyyy-MM-dd"/></td>
						<td>${item[1]}<c:if test="${item[0].linkman!=null && item[0].linkman!=''}">(${item[0].linkman})</c:if></td>
						<td>${item[0].content}</td>
						<td>${item[0].cost}</td>
						<td>${item[4]}</td>
						<td>
							<c:if test="${item[0].deliverDate!=null}"><fmt:formatDate value="${item[0].deliverDate}" pattern="yyyy-MM-dd"/></c:if>
						</td>
						<td>
							<c:if test="${item[5]!=null}"><fmt:formatDate value="${item[5]}" pattern="yyyy-MM-dd"/></c:if>
						</td>
						<td>${item[0].followerNameStr}</td>
						<td>
							<c:if test="${item[2]=='Y'}">已完工</c:if>
							<c:if test="${item[2]=='N'}">未完工</c:if>
							<br>
							<c:if test="${item[3]=='N'}">未送货</c:if>
							<c:if test="${item[3]=='P'}">未送完</c:if>
							<c:if test="${item[3]=='Y'}">已送完</c:if>
						</td>
						<td>
							<a href="javascript:doClose('${item[0].id}');">结清</a>
							<a href="javascript:doShow('${item[0].id}');">查看</a>
							<br>
							<a href="javascript:showRelBill('${item[0].billCode}');">单据跟踪</a>
							<br>
							<a href="javascript:doPrint('${item[0].id}');">打印小票</a>
						</td>
					</tr>
				</c:forEach>
			</table>
			<%@include file="../inc/Pages.jsp"%>
      </div>     
    </div>
  </div>
</div>
</body>
</html>